package com.eurekaClient.controller;

import com.eurekaClient.pojo.User;
import com.eurekaClient.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class Controller {

    @Value("${server.port}")
    String port;

    @Autowired
    private RedisService redisService;

    @RequestMapping("/hi")
    public String home(@RequestParam(value = "name", defaultValue = "EurekaClint") String name) {
        System.out.println("EurekaClint");
        return "hi " + name + ", i am from port:" + port;
    }

    @RequestMapping("/getUser")
    public User getUser(){
        String name = "quellan";
        return redisService.getUser(name);
    }
    @RequestMapping("/setUser")
    public String setUser(){
        User user = new User("aa@qq.com","quellan","123456","朱",new Date().getTime()+"");
        redisService.setUser(user);
        return "添加成功";
    }


}
